using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Runtime.Serialization;
#if SILVERLIGHT
using System.Windows;
#endif

namespace WcfService1.DTO
{
    [DataContract]
    public class JurnalDetailDTO : INotifyPropertyChanged
    {
        private CoaDTO _Coa;
        private Decimal _Debit;
        private String _Description;
        private Guid _JurnalDetailId;
        private Decimal _Kredit;
        private ObservableCollection<CoaDTO> _Coas;
        private int _No;
        private DepartemenDTO _Departemen;
        private ObservableCollection<DepartemenDTO> _Departemens;
        private ObservableCollection<PurchaseInvoiceDTO> _PurchaseInvoices;
        private ObservableCollection<SalesInvoiceDTO> _SalesInvoices;
        private SalesInvoiceDTO _SalesInvoice;
        private PurchaseInvoiceDTO _PurchaseInvoice;


        public JurnalDetailDTO()
        {
#if SILVERLIGHT
            IsVisiblePI = Visibility.Collapsed;
            IsVisibleSI = Visibility.Collapsed;
#endif
        }

        [DataMember]
        public Guid JurnalDetailId
        {
            get { return _JurnalDetailId; }
            set
            {
                _JurnalDetailId = value;
                RaisePropertyChanged("JurnalDetailId");
            }
        }


        [DataMember]
        public CoaDTO Coa
        {
            get { return _Coa; }
            set
            {
                _Coa = value;
                RaisePropertyChanged("Coa");
            }
        }


        [DataMember]
        public Decimal Debit
        {
            get { return _Debit; }
            set
            {
                _Debit = value;
                RaisePropertyChanged("Debit");
            }
        }


        [DataMember]
        public Decimal Kredit
        {
            get { return _Kredit; }
            set
            {
                _Kredit = value;
                RaisePropertyChanged("Kredit");
            }
        }


        [DataMember]
        public String Description
        {
            get { return _Description; }
            set
            {
                _Description = value;
                RaisePropertyChanged("Description");
            }
        }

        public ObservableCollection<CoaDTO> Coas
        {
            get { return _Coas; }
            set
            {
                if (ReferenceEquals(Coa, value) || value == null) return;
                _Coas = value;
                RaisePropertyChanged("Coas");
            }
        }


        public ObservableCollection<DepartemenDTO> Departemens
        {
            get { return _Departemens; }
            set
            {
                if (ReferenceEquals(Departemens, value) || value == null) return;
                _Departemens  = value;
                RaisePropertyChanged("Departemens");
            }
        }


        [DataMember]
        public DepartemenDTO Departemen
        {
            get { return _Departemen; }
            set
            {
                if (ReferenceEquals(value,Departemen) || value ==null)return;
                _Departemen = value;
                RaisePropertyChanged("Departemen");
            }
        }


        public ObservableCollection<SalesInvoiceDTO> SalesInvoices
        {
            get { return _SalesInvoices; }
            set
            {
                if (ReferenceEquals(SalesInvoices, value) || value == null) return;
                _SalesInvoices = value;
                RaisePropertyChanged("SalesInvoices");
            }
        }

        public ObservableCollection<PurchaseInvoiceDTO> PurchaseInvoices
        {
            get { return _PurchaseInvoices; }
            set
            {
                if (ReferenceEquals(_PurchaseInvoices, value) || value == null) return;
                _PurchaseInvoices = value;
                RaisePropertyChanged("PurchaseInvoices");
            }
        }


#if SILVERLIGHT
        private Visibility _IsVisiblePI;
        public Visibility IsVisiblePI
        {
            get { return _IsVisiblePI; }
            set { 
                _IsVisiblePI = value;
                RaisePropertyChanged("IsVisiblePI");
            }
        }

        private Visibility _IsVisibleSI;
        public Visibility IsVisibleSI
        {
            get { return _IsVisibleSI; }
            set
            {
                _IsVisibleSI = value;
                RaisePropertyChanged("IsVisibleSI");
            }
        }
#endif


        [DataMember]
        public PurchaseInvoiceDTO PurchaseInvoice
        {
            get { return _PurchaseInvoice; }
            set
            {
                if (ReferenceEquals(_PurchaseInvoice, value) || value == null) return;
                _PurchaseInvoice = value;
                RaisePropertyChanged("PurchaseInvoice");
            }
        }

        [DataMember]
        public SalesInvoiceDTO SalesInvoice
        {
            get { return _SalesInvoice; }
            set
            {
                if (ReferenceEquals(_SalesInvoice, value) || value == null) return;
                _SalesInvoice = value;
                RaisePropertyChanged("SalesInvoice");
            }
        }

        public int No
        {
            get { return _No; }
            set
            {
                _No = value;
                RaisePropertyChanged("No");
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        protected void RaisePropertyChanged(string propertyname)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyname));
        }
    }
}